#!/usr/bin/env python3

class Student:
    #  def __getattribute__(self, name):
        #  print("只要访问对象属性不管存在和存在都会调用 %s" % name)
        #  return True

    def __getattr__(self, name):
        print("%s 不存在" % name)

    def __setattr__(self, name, value):
        print("现在在给对象属性赋值 %s ==> %s" % (name, value))
        if name in ("age", "name", "sex"):
            self.__dict__[name] = value
        else:
            return False

    def __delattr__(self, name):
        print("删除对象属性时自动调用的方法")

def main():
    s = Student()
    #  print(hasattr(s, 'name'))
    #  print(s.name)
    #  getattr(s, "name")
    del s.name
    #  s.run = "hello"
    #  s.run
    #  print(s.age)

if __name__ == "__main__":
    main()
